package fcl.intro;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TabHost;
import fcl.friends.FriendsActivity;
import fcl.mylife.LifeMapActivity;
import fcl.pattern.PatternActivity;
import fcl.platform.DataLogger;
import fcl.platform.DataLoggerController;
import fcl.platform.R;

public class TabAct extends TabActivity {
	TabHost mTab;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
				
        TabHost tabHost = getTabHost();


 /*       

        tabHost.addTab(tabHost.newTabSpec("tab1")
                .setIndicator("Logger")
                .setContent(new Intent(this, DataLoggerController.class)));

        */

        //show map service
        tabHost.addTab(tabHost.newTabSpec("tab2")
                .setIndicator("My Life")
                .setContent(new Intent(this, LifeMapActivity.class)));
        
        tabHost.addTab(tabHost.newTabSpec("tab3")
                .setIndicator("Life Pattern")
                .setContent(new Intent(this, PatternActivity.class)));
        
        tabHost.addTab(tabHost.newTabSpec("tab4")
                .setIndicator("Friends")
                .setContent(new Intent(this, FriendsActivity.class)));


        
	}
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.life_menu, menu);
        return true;
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle item selection
        switch (item.getItemId()) {              
        case R.id.logger:
        	if(DataLogger.is_service_active(this)) {
        		DataLogger.stop_service(this);
        	} else {
        		DataLogger.start_service(this);
        	}
//        	Intent myIntent = new Intent (TabAct.this, DataLoggerController.class);
//            startActivity(myIntent);
        	return true;
        case R.id.exit:
        	finish();
            return true;
        default:
            return super.onOptionsItemSelected(item);
        }
    }
}
